package com.weiqiao.mall.repository.impl;

import com.mongodb.client.MongoCollection;
import com.weiqiao.base.dao.impl.BaseMongoDaoImpl;
import com.weiqiao.mall.repository.ICommodityLogRepository;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author PENGLIWEI
 * @createDate 2019-10-24
 */
@Repository("CommodityLogRepositoryImpl")
public class CommodityLogRepositoryImpl extends BaseMongoDaoImpl implements ICommodityLogRepository {

    private String collectionName = "commodity_log";

    @Override
    public boolean addCommodityLog(String jsons) {
        boolean flag = this.inSert(collectionName, jsons);
        return flag;
    }

    @Override
    public List<String> getCommodityLogList(Bson doc, Pageable pageable) {
        return this.getListAndPage(collectionName, doc, pageable);
    }

    @Override
    public int getCommodityLogCount(int company_id, Bson filter) {
        MongoCollection<Document> dbCollection = getCollection(collectionName);
        return (int) dbCollection.count(filter);
    }

}
